﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using UtilityLibrary;

namespace MapLibrary.Events
{
    public class PlayerInRegionTextEvent : Event
    {
        private string toDisplay;
        private float xThresholdLeft;
        private float xThresholdRight;
        private bool hasTriggered;

        public PlayerInRegionTextEvent(GameWorld world, string toDisplay, float xThresholdLeft, float xThresholdRight) : base(world)
        {
            this.toDisplay = toDisplay;
            this.xThresholdLeft = xThresholdLeft;
            this.xThresholdRight = xThresholdRight;
            this.hasTriggered = false;
        }

        public override void Update()
        {
            if (world.CurrentLevel.Player.Body.Position.X > xThresholdLeft &&
                world.CurrentLevel.Player.Body.Position.X < xThresholdRight)
            {
                hasTriggered = true;
            }
            else
                hasTriggered = false;
        }

        public override void Act()
        {
            //do nothing
        }

        public override void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch batch)
        {
            if (hasTriggered)
            {
                PrimitiveBrush.RenderText(batch, toDisplay, new Microsoft.Xna.Framework.Vector2(20, 700));
            }
        }
    }
}
